package com.acmen.ump.core.generator.config;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.generator.config.PackageConfig;


/**
 * 重写PackageConfig，避免生成文件Package错误
 * @author ftpolaris
 * @date 2019/08/24
 */
public class MyPackageConfig extends PackageConfig {

    private String parent = "com.baomidou";
    private String moduleName = null;
    private String controller = "api.controller";
    private String entity = "entity.model";
    private String service = "service";
    private String serviceImpl = "service";
    private String mapper = "mapper";

    @Override
    public String getParent() {
        return this.parent;
    }

    @Override
    public MyPackageConfig setParent(final String parent) {
        this.parent = parent;
        return this;
    }

    @Override
    public String getModuleName() {
        return this.moduleName;
    }

    @Override
    public MyPackageConfig setModuleName(final String moduleName) {
        this.moduleName = moduleName;
        return this;
    }

    @Override
    public String getController() {
        return StringUtils.isNotEmpty(this.moduleName) ? controller + "." + this.moduleName : this.controller;
    }

    @Override
    public String getEntity() {
        return StringUtils.isNotEmpty(this.moduleName) ? entity + "." + this.moduleName : this.entity;
    }

    @Override
    public String getService() {
        return StringUtils.isNotEmpty(this.moduleName) ? service + "." + this.moduleName : this.service;
    }

    @Override
    public String getServiceImpl() {
        return StringUtils.isNotEmpty(this.moduleName) ? serviceImpl + "." + this.moduleName + ".Impl" : this.serviceImpl + ".Impl";
    }

    @Override
    public String getMapper() {
        return StringUtils.isNotEmpty(this.moduleName) ? mapper + "." + this.moduleName : this.mapper;
    }

}
